package com.example.demo.converter;

import com.example.demo.dao.Schedule;
import com.example.demo.dto.ScheduleDTO;
import java.util.HashSet;
import java.util.Set;

public class ScheduleConverter {
    public static ScheduleDTO convertSchedule(Schedule schedule)
    {
        ScheduleDTO scheduleDTO = new ScheduleDTO();
        scheduleDTO.setId(schedule.getId());
        scheduleDTO.setDate(schedule.getDate());
        scheduleDTO.setContent(schedule.getContent());
        scheduleDTO.setAiSuggestion(schedule.getAiSuggestion());
        scheduleDTO.setDateId(schedule.getDateId());
        scheduleDTO.setUserDTO(UserConverter.convertUser(schedule.getUser()));
        scheduleDTO.setOutfitDTO(OutfitConverter.convertOutfit(schedule.getOutfit()));
        return scheduleDTO;
    }
    public static Schedule convertSchedule(ScheduleDTO scheduleDTO)
    {
        Schedule schedule = new Schedule();
        schedule.setId(scheduleDTO.getId());
        schedule.setDate(scheduleDTO.getDate());
        schedule.setContent(scheduleDTO.getContent());
        schedule.setAiSuggestion(scheduleDTO.getAiSuggestion());
        schedule.setDateId(scheduleDTO.getDateId());
        schedule.setUser(UserConverter.convertUser(scheduleDTO.getUserDTO()));
        schedule.setOutfit(OutfitConverter.convertOutfit(scheduleDTO.getOutfitDTO()));
        return schedule;
    }
    public static Set<ScheduleDTO> convertToScheduleDTOSet(Set<Schedule> schedules)
    {
        Set<ScheduleDTO> scheduleDTOSet = new HashSet<>();
        for(Schedule schedule : schedules)
        {
            scheduleDTOSet.add(convertSchedule(schedule));
        }
        return scheduleDTOSet;
    }
    public static Set<Schedule> convertToScheduleSet(Set<ScheduleDTO> schedules)
    {
        Set<Schedule> scheduleSet = new HashSet<>();
        for(ScheduleDTO scheduleDTO : schedules)
        {
            scheduleSet.add(convertSchedule(scheduleDTO));
        }
        return scheduleSet;
    }
}
